{% extends "base_content.html" %}
{% load engine_tags %}
{% load static %}

{% block headtitle %}
    Managing Access: {{ project.name }}
{% endblock %}

{% block content %}

    {% form_errors form %}

    <div class="centerform">
        <div class="manage_users">
            <div class="ui segment">
                <div class="ui search">
                    <form method="get" action="{% url 'project_users' project.uid %} ">
                        <div class="ui fluid input">

                            <input type="text" name="q" value="{{ q }}" placeholder="Search for users">

                            <button class="ui large basic icon button" type="submit" formmethod="get">
                                <i class="small search icon"></i>
                            </button>
                        </div>

                    </form>
                </div>

                {% if q %}
                    <div class="ui header">
                        <i class="search icon"></i>
                        Search results
                    </div>
                    <div class="ui success message">
                        Filtering for : <b>{{ q }}</b>
                        &bull; <a href="{% url 'project_users' project.uid %}"><i class="undo icon"></i>Clear</a>
                    </div>

                    <div class="ui vertical segment">
                        <div class="ui relaxed divided list">
                            {% for target in targets %}
                                {% access_form project=project user=target %}
                            {% endfor %}
                        </div>
                    </div>
                {% endif %}
            </div>

            {% if have_access %}
                <div class="ui header">
                    <i class="users icon"></i>
                    Users with access to {{ project.name }}
                </div>

                <div class="ui vertical segment">
                    <div class="ui relaxed divided list">
                        {% for access in have_access %}
                            {% access_form project=project user=access.user extra_class='inputcolor' %}

                        {% endfor %}
                    </div>
                </div>
            {% endif %}
        </div>
    </div>

{% endblock %}